This function (and no other code) controls locking of the door, if the drive allows this. The value of lock controls the desired locking state: